﻿//3.无重复字符的最长子串
class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int len = 0;
        int hash[128] = { 0 };
        for (size_t left = 0, right = 0; right < s.size(); right++)
        {
            hash[s[right]]++;
            while (hash[s[right]] == 2)
            {
                hash[s[left]]--;
                left++;
            }
            if (right - left + 1 > len)
            {
                len = right - left + 1;
            }
        }
        return len;
    }
};